package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzDianping;
import com.ruoyi.system.service.IDzDianpingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户点评Controller
 * 
 * @author ruoyi
 * @date 2023-08-16
 */
@RestController
@RequestMapping("/system/dianping")
public class DzDianpingController extends BaseController
{
    @Autowired
    private IDzDianpingService dzDianpingService;

    /**
     * 查询用户点评列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DzDianping dzDianping)
    {
        startPage();
        List<DzDianping> list = dzDianpingService.selectDzDianpingList(dzDianping);
        return getDataTable(list);
    }

    /**
     * 导出用户点评列表
     */
    @Log(title = "用户点评", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzDianping dzDianping)
    {
        List<DzDianping> list = dzDianpingService.selectDzDianpingList(dzDianping);
        ExcelUtil<DzDianping> util = new ExcelUtil<DzDianping>(DzDianping.class);
        util.exportExcel(response, list, "用户点评数据");
    }

    /**
     * 获取用户点评详细信息
     */
    @GetMapping(value = "/{dpId}")
    public AjaxResult getInfo(@PathVariable("dpId") Long dpId)
    {
        return AjaxResult.success(dzDianpingService.selectDzDianpingByDpId(dpId));
    }

    /**
     * 新增用户点评
     */
    @Log(title = "用户点评", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzDianping dzDianping)
    {
        return toAjax(dzDianpingService.insertDzDianping(dzDianping));
    }

    /**
     * 修改用户点评
     */
    @Log(title = "用户点评", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzDianping dzDianping)
    {
        return toAjax(dzDianpingService.updateDzDianping(dzDianping));
    }

    /**
     * 删除用户点评
     */
    @Log(title = "用户点评", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dpIds}")
    public AjaxResult remove(@PathVariable Long[] dpIds)
    {
        return toAjax(dzDianpingService.deleteDzDianpingByDpIds(dpIds));
    }
}
